package com.neutech.solar.util;

import com.neutech.solar.constant.Constant;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class ImageUtil {
    public static Map<String,Image>  maps = new HashMap<>();
    static {
        maps.put("Earth",ImageUtil.getImage("Earth.png"));
        maps.put("Mercury",ImageUtil.getImage("Mercury.png"));
        maps.put("Venus",ImageUtil.getImage("Venus.png"));
        maps.put("Mars",ImageUtil.getImage("Mars.png"));
        maps.put("Jupiter",ImageUtil.getImage("Jupiter.png"));
        maps.put("Saturn",ImageUtil.getImage("Saturn.png"));
        maps.put("smallPlanet",ImageUtil.getImage("Pluto.png"));
    }
    public ImageUtil(){}

    public static Image getImage(String path) {
        URL url = ImageUtil.class.getClassLoader().getResource(Constant.IMAGE_PATH_PRE + path);

        BufferedImage img = null;

        try {
            img =  ImageIO.read(url);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return img;
    }
}
